import Vue from 'vue'
import Router from 'vue-router'

Vue.use(Router)

/* Layout */
import Layout from '@/layout'

/**
 * Note: sub-menu only appear when route children.length >= 1
 * Detail see: https://panjiachen.github.io/vue-element-admin-site/guide/essentials/router-and-nav.html
 *
 * hidden: true                   if set true, item will not show in the sidebar(default is false)
 * alwaysShow: true               if set true, will always show the root menu
 *                                if not set alwaysShow, when item has more than one children route,
 *                                it will becomes nested mode, otherwise not show the root menu
 * redirect: noRedirect           if set noRedirect will no redirect in the breadcrumb
 * name:'router-name'             the name is used by <keep-alive> (must set!!!)
 * meta : {
    roles: ['admin','editor']    control the page roles (you can set multiple roles)
    title: 'title'               the name show in sidebar and breadcrumb (recommend set)
    icon: 'svg-name'/'el-icon-x' the icon show in the sidebar
    breadcrumb: false            if set false, the item will hidden in breadcrumb(default is true)
    activeMenu: '/example/list'  if set path, the sidebar will highlight the path you set
  }
 */

/**
 * constantRoutes
 * a base page that does not have permission requirements
 * all roles can be accessed
 */
export const constantRoutes = [
  {
    path: '/login',
    component: () => import('@/views/login/index'),
    hidden: true
  },

  {
    path: '/404',
    component: () => import('@/views/404'),
    hidden: true
  },

  {
    path: '/',
    component: Layout,
    redirect: '/dashboard',
    children: [{
      path: 'dashboard',
      name: 'Dashboard',
      component: () => import('@/pages/dashboard/index'),
      meta: { title: '首页大屏', icon: 'dashboard' }
    }]
  },
  {
    path: '/statistics',
    component: Layout,
    meta:{title:"3D数据",icon: '5' },
    children: [
      {
        path: 'test',
        name: 'statistics_test',
        component: () => import('@/pages/statistics/Test'),
        meta: { title: '数据可视化'}
      }
    ]
  },
  {
    path: '/application',
    component: Layout,
    children: [
      {
        path: 'index',
        name: 'application',
        component: () => import('@/pages/Application/Application'),
        meta: { title: '应用管理', icon: '1' }
      },
      {
        path: 'create',
        hidden:true,
        name: 'applicationCreate',
        component: () => import('@/pages/Application/ApplicationCreate'),
        meta: { title: '应用创建', icon: '1' }
  },
    ]
  },
 
  {
    path: '/article',
    component: Layout,
    children: [
      {
        path: 'index',
        name: 'article',
        component: () => import('@/pages/Article/article'),
        meta: { title: '文章管理', icon: '2' }
      },
  {
        hidden:true,
        path: 'create',
        name: 'articleCreate',
        component: () => import('@/pages/Article/articleCreate'),
        meta: { title: '文章创建', icon: '2' }
  },
]
},
  {
    path: '/baseConfig',
    component: Layout,
    children: [
      {
        path: 'index',
        name: 'baseConfig',
        component: () => import('@/pages/BaseConfig/baseConfig'),
        meta: { title: '配置管理', icon: '3' }
      },
      {
        hidden : true,
        path: 'create',
        name: 'baseConfigCreate',
        component: () => import('@/pages/BaseConfig/baseConfigCreate'),
        meta: { title: '创建配置', icon: '3' }
      }
    ]
  },
  {
  path: '/baseLog',
  component: Layout,
  children: [
    {
      path: 'index',
      name: 'baseLog',
      component: () => import('@/pages/BaseLog/baseLog'),
      meta: { title: '日志管理', icon: '4' }
    },
    {
      hidden : true,
      path: 'create',
      name: 'baseLogCreate',
      component: () => import('@/pages/BaseLog/baseLogCreate'),
      meta: { title: '创建日志', icon: '4' }
    }
  ]
},
  {
    path: '/baseFile',
    component: Layout,
    children: [
      {
        path: 'index',
        name: 'baseFile',
        component: () => import('@/pages/BaseFile/baseFile'),
        meta: { title: '文件管理', icon: '5' }
      },
      {
        hidden : true,
        path: 'create',
        name: 'baseFileCreate',
        component: () => import('@/pages/BaseFile/baseFileCreate'),
        meta: { title: '文件创建', icon: '5' }
      }
    ]
  },
  {
    path: '/basePrivilege',
    component: Layout,
    children: [
      {
        path: 'index',
        name: 'basePrivilege',
        component: () => import('@/pages/BasePrivilege/basePrivilege'),
        meta: { title: '权限管理', icon: '6' }
      },
      {
        hidden : true,
        path: 'create',
        name: 'basePrivilegeCreate',
        component: () => import('@/pages/BasePrivilege/basePrivilegeCreate'),
        meta: { title: '创建权限', icon: '6' }
      }
    ]
  },
  {
    path: '/baseRolePrivilege',
    component: Layout,
    children: [
      {
        path: 'index',
        name: 'baseRolePrivilege',
        component: () => import('@/pages/BaseRolePrivilege/baseRolePrivilege'),
        meta: { title: '角色权限管理', icon: '7' }
      },
      {
        hidden : true,
        path: 'create',
        name: 'baseRolePrivilegeCreate',
        component: () => import('@/pages/BaseRolePrivilege/baseRolePrivilegeCreate'),
        meta: { title: '创建角色权限', icon: '7' }
      }
    ]
  },
  {
    path: '/categoary',
    component: Layout,
    children: [
      {
        path: 'index',
        name: 'categoary',
        component: () => import('@/pages/Categoary/categoary'),
        meta: { title: '种类管理', icon: '8' }
      },
      {
        hidden : true,
        path: 'create',
        name: 'categoaryCreate',
        component: () => import('@/pages/Categoary/categoaryCreate'),
        meta: { title: '种类创建', icon: '8' }
      }
    ]
  },
  {
    path: '/comment',
    component: Layout,
    children: [
      {
        path: 'index',
        name: 'comment',
        component: () => import('@/pages/Comment/comment'),
        meta: { title: '评论管理', icon: '9' }
      },
      {
        hidden : true,
        path: 'create',
        name: 'commentCreate',
        component: () => import('@/pages/Comment/commentCreate'),
        meta: { title: '创建评论管理', icon: '9' }
      }
    ]
  },
  {
    path: '/counsel',
    component: Layout,
    children: [
      {
        path: 'index',
        name: 'counsel',
        component: () => import('@/pages/Counsel/counsel'),
        meta: { title: '咨询管理', icon: '10' }
      },
      {
        hidden : true,
        path: 'create',
        name: 'counselCreate',
        component: () => import('@/pages/Counsel/counselCreate'),
        meta: { title: '创建', icon: '10' }
      }
    ]
  },
  {
    path: '/dataset',
    component: Layout,
    children: [
      {
        path: 'index',
        name: 'dataset',
        component: () => import('@/pages/Dataset/dataset'),
        meta: { title: '模型训练', icon: '19' }
      },
      {
        hidden : true,
        path: 'create',
        name: 'datasetCreate',
        component: () => import('@/pages/Dataset/datasetCreate'),
        meta: { title: '创建模型', icon: '19' }
      }
    ]
  },

  {
    path: '/greenHouse',
    component: Layout,
    children: [
      {
        path: 'index',
        name: 'greenHouse',
        component: () => import('@/pages/GreenHouse/greenHouse'),
        meta: { title: '模型管理', icon: '13' }
      },
      {
        path: 'create',
        hidden:true,
        name: 'greenhouse_create',
        component: () => import('@/pages/GreenHouse/greenHouseCreate'),
        meta: { title: '创建模型管理', icon: '13' }
      }
    ]
  },
  {
    path: '/interFace',
    component: Layout,
    children: [
      {
        path: 'index',
        name: 'interFace',
        component: () => import('@/pages/InterFace/interFace'),
        meta: { title: '接口管理', icon: '14' }
      },
      {
        path: 'create',
        hidden:true,
        name: 'interFaceCreate',
        component: () => import('@/pages/InterFace/interFaceCreate'),
        meta: { title: '创建接口管理', icon: '14' }
      }
    ]
  },
  {
    path: '/module',
    component: Layout,
    children: [
      {
        path: 'index',
        name: 'module',
        component: () => import('@/pages/Module/module'),
        meta: { title: '模型发布', icon: '15' }
      },
      {
        hidden:true,
        path: 'create',
        name: 'moduleCreate',
        component: () => import('@/pages/Module/moduleCreate'),
        meta: { title: '创建模型发布', icon: '15' }
      }
    ]
  },
  {
    path: '/userRole',
    component: Layout,
    children: [
      {
        path: 'index',
        name: 'userRole',
        component: () => import('@/pages/UserRole/userRole'),
        meta: { title: '用户角色', icon: '16' }
      },
      {
        hidden:true,
        path: 'create',
        name: 'userRoleCreate',
        component: () => import('@/pages/UserRole/userRoleCreate'),
        meta: { title: '创建用户角色', icon: '16' }
      }
    ]
  },
  {
    path: '/user',
    component: Layout,
    children: [
      {
        path: 'index',
        name: 'user',
        component: () => import('@/pages/User/user'),
        meta: { title: '我的信息', icon: '17' }
      },
      {
        hidden:true,
        path: 'create',
        name: 'userCreate',
        component: () => import('@/pages/User/usercreate'),
        meta: { title: '创建我的信息', icon: '17' }
      }
    ]
  },
  
  {
    path: '/baseRole',
    component: Layout,
    children: [
      {
        path: 'index',
        name: 'baseRole',
        component: () => import('@/pages/BaseRole/baseRole'),
        meta: { title: '基本角色', icon: '18' }
      },
      {
        hidden:true,
        path: 'create',
        name: 'baseRoleCreate',
        component: () => import('@/pages/BaseRole/baseRoleCreate'),
        meta: { title: '创建基本角色', icon: '18' }
      }
    ]
  },
  {
    path: '/recognition',
    component: Layout,
    children: [
      {
        path: 'index',
        name: 'recognition',
        component: () => import('@/pages/Recognition/recognition'),
        meta: { title: '图像识别', icon: '9' }
      }
    ]
  },
  {
    path: '/file',
    component: Layout,
    meta:{title:"训练数据",icon: '1' },
    children: [
      {
        path: 'dataset',
        name: 'file_dataset',
        component: () => import('@/pages/file/Dataset'),
        meta: { title: '训练数据'}
      },
      {
        path: 'dataset_file',
        name: 'file_dataset_file',
        hidden:true,
        component: () => import('@/pages/file/DatasetFile'),
        meta: { title: '训练数据文件'}
      }
    ]
  },
  // 404 page must be placed at the end !!!
  { path: '*', redirect: '/404', hidden: true }
]

const createRouter = () => new Router({
  // mode: 'history', // require service support
  scrollBehavior: () => ({ y: 0 }),
  routes: constantRoutes
})

const router = createRouter()

// Detail see: https://github.com/vuejs/vue-router/issues/1234#issuecomment-357941465
export function resetRouter() {
  const newRouter = createRouter()
  router.matcher = newRouter.matcher // reset router
}

export default router
